﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using My.Admin.Dto.User;
using My.Admin.Model.System;
using My.Admin.Service.System.IService;
using My.Core.DynamicWebApi.Attributes;
using System.ComponentModel;

namespace My.Admin.Dynamic
{
	[Service("SysOrgController")]
	public class SysOrgController
	{
		private readonly ISysOrgService _sysOrgRep;

		public SysOrgController(ISysOrgService sysOrgRep)
		{
			_sysOrgRep = sysOrgRep;
		}

		/// <summary>
		/// 获取机构列表
		/// </summary>
		/// <returns></returns>
		[DisplayName("获取机构列表")]
		[Authorize]
		public async Task<List<SysOrg>> GetList([FromQuery] OrgInput input)
		{
			return await _sysOrgRep.GetList(input);
		}

		/// <summary>
		/// 增加机构
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[HttpPost]
		[Authorize]
		public async Task<long> AddOrg(AddOrgInput input)
		{
			return await _sysOrgRep.AddOrg(input);
		}

		/// <summary>
		/// 更新机构
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[HttpPost]
		[Authorize]
		public async Task UpdateOrg(UpdateOrgInput input)
		{
			await _sysOrgRep.UpdateOrg(input);
		}

		/// <summary>
		/// 删除机构
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[HttpPost]
		[Authorize]
		public async Task DeleteOrg(DeleteOrgInput input)
		{
			await _sysOrgRep.DeleteOrg(input);
		}
	}
}
